﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Register.IDAL;
using Register.Model;
using Register.DBUtility;
using Register.Command;
using System.Data;
using System.Data.SqlClient;
namespace Register.DAL
{
    /// <summary> 
    /// FileName: DoctorPersonInfoDAL.cs    
    /// CLRVersion: 4.0.30319.269    
    /// Author: DoubleZ    
    /// Corporation:     
    /// Description:     
    /// DateTime: 2012/7/7 10:02:08    
    /// </summary>
  public  class DoctorPersonInfoDAL:IDoctorPersonInfoDAL
    
  {
      #region 获取医生用户信息

      public  List<DoctorUserInfo> GetDoctorUserInfo(string doctorUserID) {
          String sql = "   select  top 1 DoctorUser_ID,Doctor_ID,DoctorUser_UserName,DoctorUser_Password,DoctorUser_LastRegTime from System_doctorUserInfo where DoctorUser_ID='" + doctorUserID + "'";
            List<DoctorUserInfo> list = new List<DoctorUserInfo>();
            SqlDataReader reader = DbHelperSQL.ExecuteReader(sql);
            list = ChangeReaderToDoctorUserList(reader);
            reader.Close();
            return list;

      }
       
       private List<DoctorUserInfo> ChangeReaderToDoctorUserList(SqlDataReader reader)
        {
            List<DoctorUserInfo> list = new List<DoctorUserInfo>();
            while (reader.Read())
            {
               DoctorUserInfo paramter = new DoctorUserInfo();
               paramter.DoctorUser_ID=reader.GetString(0);
                paramter.Doctor_ID=reader.GetString(1);
                paramter.DoctorUser_UserName=reader.GetString(2);
                paramter.DoctorUser_Password = reader.GetString(3);
                //临时赋值
                paramter.DoctorUser_LastRegTime=DateTime.Now;//Convert.ToDateTime(reader.GetString(4));
                list.Add(paramter);
            }
            return list;
        }
      #endregion

      #region 获取医生信息
     public List<DoctorInfo> GetDoctorInfo(string doctorID) {
         String sql = " select  top 1 Departments_ID,Doctor_No,Doctor_Name,Doctor_Gender,Doctor_DateOfBirth,Doctor_Position,Doctor_Education,Doctor_Resume,Doctor_Phone,Doctor_Email,Doctor_Picture,Doctor_Specialty from System_doctorInfo  where Doctor_ID='" + doctorID + "'";
            List<DoctorInfo> list = new List<DoctorInfo>();
            SqlDataReader reader = DbHelperSQL.ExecuteReader(sql);
            list = ChangeReaderToDoctorInfoList(reader);
            reader.Close();
            return list;
      
      }
     private List<DoctorInfo> ChangeReaderToDoctorInfoList(SqlDataReader reader)
        {
            List<DoctorInfo> list = new List<DoctorInfo>();
            while (reader.Read())
            {
                DoctorInfo paramter = new DoctorInfo();
                paramter.Departments_ID = reader.GetString(0);
                paramter.Doctor_No = reader.GetString(1);
                paramter.Doctor_Name = reader.GetString(2);
                paramter.Doctor_Gender = reader.GetString(3);
                paramter.Doctor_DateOfBirth = reader.GetDateTime(4);
                paramter.Doctor_Position = reader.GetString(5);
                paramter.Doctor_Education = reader.GetString(6);
                paramter.Doctor_Resume = reader.GetString(7);
                paramter.Doctor_Phone = reader.GetString(8);
                paramter.Doctor_Email = reader.GetString(9);
                paramter.Doctor_Picture = reader.GetString(10);
                paramter.Doctor_Specialty = reader.GetString(11);
                list.Add(paramter);
            }
            return list;
        }
      #endregion
  }
}
